// antd 按需加载
import { Toast } from '@ant-design/react-native';

import store from '../../../store/store.js'
import * as ActionTypes from '../../../constants/constants.js'
import { isUser, isWxUser, path, saveData, loadData, removeData, requstPromise } from '../../../util/utils.js'
import request from '../../../api/request.js'

export async function getUserInfo(options) {
    const { dispatch } = this.props
    // const loading = Toast.loading('加载中', 0, null, false)
    const res = await request.MemberController.userInfo(options)
    
    if (!res.error) {
        dispatch({
            type: ActionTypes.userInfo,
            data: res.data.data
        })
        saveData('userInfo', res.data.data)
    }
    return requstPromise(res)
}

export async function dashboard(options) {
    const { dispatch } = this.props
    const res = await request.MemberController.dashboard(options)
    if (!res.error) {
        dispatch({
            type: ActionTypes.userDashboard,
            data: res.data.data
        })
    }
    return requstPromise(res)
}
